package com.agv.web;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMessage;

import com.agv.web.util.UUIDGen;

/**
 * @author NAAT
 * 
 */
public class MonitoringAction extends Action {

	/**
	 * 
	 */
	private final String ERROR_GENERAL = "error.general";

	/**
	 * 
	 */
	private final String ERROR = "error";

	/**
	 * @param request
	 * @param e
	 */
	public void initMonitorAction(HttpServletRequest request,
			String employeeNumber) {
	}

	/**
	 * @param request
	 * @param e
	 */
	public void monitoringError(HttpServletRequest request, Exception e) {
		ActionErrors errors = new ActionErrors();
		String errorCode = UUIDGen.genUUID();
		if (e.getCause() != null) {
			errors.add(ERROR, new ActionMessage(ERROR_GENERAL,
					new Object[] { errorCode }));
		} else {
			errors.add(ERROR, new ActionMessage(ERROR_GENERAL,
					new Object[] { errorCode }));
		}
		saveMessages(request, errors);
	}
}
